home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 17 / AMIGAplus Sonderheft 17 (1999)(ICP)(DE)[!].iso / mui / developer / c / examples / boopsidoor.c < prev    next >
C/C++ Source or Header  |  1977-12-31  |  4KB  |  142 lines

  1. /*
  2. ** This program needs at least V39 include files !
  3. */
  4.  
  5. #include "demo.h"
  6.  
  7. #include "gadgets/colorwheel.h"
  8. #include "intuition/icclass.h"
  9. #include "intuition/gadgetclass.h"
  10.  
  11.  
  12. /*
  13. ** Gauge object macro to display colorwheels
  14. ** hue and saturation values.
  15. */
  16.  
  17. #define InfoGauge GaugeObject,\
  18.     GaugeFrame    , \
  19.     MUIA_Background  , MUII_BACKGROUND,\
  20.     MUIA_Gauge_Max   , 16384,\
  21.     MUIA_Gauge_Divide, 262144,\
  22.     MUIA_Gauge_Horiz , TRUE,\
  23.     End
  24.  
  25.  
  26. int main(int argc,char *argv[])
  27. {
  28.     struct Library *ColorWheelBase;
  29.     APTR app,window,Wheel,Hue,Sat;
  30.  
  31.     init();
  32.  
  33.     if (!(ColorWheelBase = OpenLibrary("gadgets/colorwheel.gadget",0)))
  34.         fail(NULL,"colorwheel boopsi gadget not available\n");
  35.  
  36.     app = ApplicationObject,
  37.         MUIA_Application_Title      , "BoopsiDoor",
  38.         MUIA_Application_Version    , "$VER: BoopsiDoor 17.6 (18.08.96)",
  39.         MUIA_Application_Copyright  , "©1992/93, Stefan Stuntz",
  40.         MUIA_Application_Author     , "Stefan Stuntz",
  41.         MUIA_Application_Description, "Show a boopsi colorwheel with MUI.",
  42.         MUIA_Application_Base       , "BOOPSIDOOR",
  43.  
  44.         SubWindow, window = WindowObject,
  45.             MUIA_Window_Title, "BoopsiDoor",
  46.             MUIA_Window_ID   , MAKE_ID('B','O','O','P'),
  47.  
  48.             WindowContents, VGroup,
  49.  
  50.                 Child, ColGroup(2),
  51.                     Child, Label("Hue:"       ), Child, Hue = InfoGauge,
  52.                     Child, Label("Saturation:"), Child, Sat = InfoGauge,
  53.                     Child, RectangleObject,MUIA_Weight,0,End, Child, ScaleObject, End,
  54.                     End,
  55.  
  56.                 Child, Wheel = BoopsiObject,  /* MUI and Boopsi tags mixed */
  57.  
  58.                     GroupFrame,
  59.  
  60.                     MUIA_Boopsi_ClassID  , "colorwheel.gadget",
  61.  
  62.                     MUIA_Boopsi_MinWidth , 30, /* boopsi objects don't know */
  63.                     MUIA_Boopsi_MinHeight, 30, /* their sizes, so we help   */
  64.  
  65.                     MUIA_Boopsi_Remember , WHEEL_Saturation, /* keep important values */
  66.                     MUIA_Boopsi_Remember , WHEEL_Hue,        /* during window resize  */
  67.  
  68.                     MUIA_Boopsi_TagScreen, WHEEL_Screen, /* this magic fills in */
  69.                     WHEEL_Screen         , NULL,         /* the screen pointer  */
  70.  
  71.                     GA_Left     , 0,
  72.                     GA_Top      , 0, /* MUI will automatically     */
  73.                     GA_Width    , 0, /* fill in the correct values */
  74.                     GA_Height   , 0,
  75.  
  76.                     ICA_TARGET  , ICTARGET_IDCMP, /* needed for notification */
  77.  
  78.                     WHEEL_Saturation, 0, /* start in the center */
  79.  
  80.                     MUIA_FillArea, TRUE, /* use this because it defaults to FALSE 
  81.                                             for boopsi gadgets but the colorwheel
  82.                                             doesnt bother about redrawing its backgorund */
  83.  
  84.                     End,
  85.                 End,
  86.             End,
  87.         End;
  88.  
  89.     if (!app)
  90.     {
  91.         if (ColorWheelBase) CloseLibrary(ColorWheelBase);
  92.         fail(app,"Failed to create Application.");
  93.     }
  94.  
  95.  
  96. /*
  97. ** you can react on every boopsi notification
  98. ** event as on any other MUI attribute.
  99. */
  100.  
  101.     DoMethod(Wheel,MUIM_Notify,WHEEL_Hue       ,MUIV_EveryTime,Hue,4,MUIM_Set,MUIA_Gauge_Current,MUIV_TriggerValue);
  102.     DoMethod(Wheel,MUIM_Notify,WHEEL_Saturation,MUIV_EveryTime,Sat,4,MUIM_Set,MUIA_Gauge_Current,MUIV_TriggerValue);
  103.  
  104.  
  105.     DoMethod(window,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  106.  
  107.  
  108. /*
  109. ** This is the ideal input loop for an object oriented MUI application.
  110. ** Everything is encapsulated in classes, no return ids need to be used,
  111. ** we just check if the program shall terminate.
  112. ** Note that MUIM_Application_NewInput expects sigs to contain the result
  113. ** from Wait() (or 0). This makes the input loop significantly faster.
  114. */
  115.  
  116.     set(window,MUIA_Window_Open,TRUE);
  117.  
  118.     {
  119.         ULONG sigs = 0;
  120.  
  121.         while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  122.         {
  123.             if (sigs)
  124.             {
  125.                 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  126.                 if (sigs & SIGBREAKF_CTRL_C) break;
  127.             }
  128.         }
  129.     }
  130.  
  131.     set(window,MUIA_Window_Open,FALSE);
  132.  
  133.  
  134.  
  135. /*
  136. ** shut down.
  137. */
  138.  
  139.     if (ColorWheelBase) CloseLibrary(ColorWheelBase);
  140.     fail(app,NULL);
  141. }
  142.